/*
 * Created: 2022-08-31 12:12:08
 * Author : 涛涛涛
 */

import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
import { Artwork_Res, Artwork_Web } from '@/pages/_server/_class/Product/Artwork';
/** 通过ID获得艺术品信息 */
export const apiGetArtworkById = async (id: string) => {
    const response1: MyResponse<Artwork_Res> = await sendRequest(id);
    const webData = new Artwork_Web().immit_response(response1.data);
    const resonlse2: MyResponse<Artwork_Web> = { ...response1, data: webData };
    return resonlse2;
};

const sendRequest = async (id: string) => {
    let response1: MyResponse<Artwork_Res>;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: `artwork?id=${id}`,
            method: 'GET',
        });
    } else {
        response1 = {
            code: '200',
            message: 'ok',
            data: {
                id: '1',
                name: '猪面',
                cataId: '1',
                authorId: '1',
                iconUrl: '/nft-icon/p2.png',
                views: '0',
                likes: '0',
                intro: '这是梵高的作品...',
            },
        };
    }
    return response1;
};
